export default class Scope{
  constructor(options){
    this.name = options.name;
    this.parent = options.parent;
    this.names = options.params ||[];
  }
  add(name){
    this.names.push(name);
  }
  fundDefingScope(name){
    if(this.names.includes(name)){
      return this;
    }
    if(this.parent){
      return this.parent.fundDefingScope(name);
    }
    return null;
  }
  
}

// let globalScope = new Scope({
//   name:"globalScope",
//   params:[],
//   parent:null
// })
// globalScope.add('a');


// let oneScope = new Scope({
//   name:"oneScope",
//   params:[],
//   parent:globalScope
// })
// oneScope.add('b');


// let twoScope = new Scope({
//   name:"twoScope",
//   params:['age'],
//   parent:oneScope
// })
// twoScope.add('c')


// let ascope =  twoScope.fundDefingScope('a');